package struts.admin.action;

import org.apache.struts2.json.annotations.JSON;

import com.opensymphony.xwork2.ActionSupport;

public class LoginAction extends ActionSupport {
	private String userName;
	private String password;
	private String result;
	private String msg; // 结果信息属性

	public String getResult() {
		return result;
	}

	public void setResult(String result) {
		this.result = result;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	@JSON(serialize=false)
	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	@JSON(serialize=false)
	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	/**
	 *处理用户请求的excute()方法
	 * 
	 *@return结果导航字符串
	 *@throws Exception
	 */
	public String execute() throws Exception {
		if ("test".equals(this.userName) && "test".equals(this.password)) {
			result = "true";
			msg = "登录成功，欢迎" + this.userName;
			return this.SUCCESS;
		} else {
			result = "false";
			msg = "登录失败，用户名或密码错";
			return this.LOGIN;
		}
	}
}
